/*
 * SPDX-License-Identifier: Apache-2.0
 * Copyright Blazebit
 */

package com.blazebit.persistence.testsuite;

import static org.junit.Assert.assertEquals;

import org.junit.Test;

import com.blazebit.persistence.CriteriaBuilder;
import com.blazebit.persistence.testsuite.AbstractCoreTest;
import com.blazebit.persistence.testsuite.entity.Document;

/**
 *
 * @author Christian Beikov
 * @author Moritz Becker
 * @since 1.0.0
 */
public class IsNullTest extends AbstractCoreTest {
    
    @Test
    public void testIsNull() {
        CriteriaBuilder<Document> criteria = cbf.create(em, Document.class, "d");
        criteria.where("d.name").isNull();

        assertEquals("SELECT d FROM Document d WHERE d.name IS NULL", criteria.getQueryString());
        criteria.getResultList();
    }

    @Test
    public void testIsNotNull() {
        CriteriaBuilder<Document> criteria = cbf.create(em, Document.class, "d");
        criteria.where("d.name").isNotNull();

        assertEquals("SELECT d FROM Document d WHERE d.name IS NOT NULL", criteria.getQueryString());
        criteria.getResultList();
    }
}
